import {
    getOtherInformation,
    getOtherArray,
    getOtherNft,
    getOtherSelling,
    getOtherColletion
} from '@/api'

const state = {
    artistInfo: {},
    artistCollections: {},
    artistCreated: {},
    artistSelling: {},
    artistLikes: {}
}

const mutations = {
    ARTISTINFO(context, data) {
        context.artistInfo = data
    },
    ARTISTCOLLECTIONS(context, data) {
        context.artistCollections = data
    },
    ARTISTCREATED(context, data) {
        context.artistCreated = data
    },
    ARTISTSELLING(context, data) {
        context.artistSelling = data
    },
    ARTISTLIKES(context, data) {
        context.artistLikes = data
    },
}

const actions = {
    async artistInfo({
        commit
    }, params) {
        let {
            user_address,
            other_address
        } = params
        let result = await getOtherInformation(user_address, other_address)
        commit('ARTISTINFO', result[0])
    },
    async artistCollections({commit}, params){
        let result = await getOtherArray(params)
        commit('ARTISTCOLLECTIONS', result)
    },
    async artistCreated({commit}, params){
        let result = await getOtherNft(params)
        commit('ARTISTCREATED', result)
    },
    async artistSelling({commit}, params){
        let result = await getOtherSelling(params)
        commit('ARTISTSELLING', result)
    },
    async artistLikes({commit}, params){
        let result = await getOtherColletion(params)
        commit('ARTISTLIKES', result)
    },
}

const getters = {
    artist_address(state) {
        return state.artistInfo.user_address
    }
}

export default {
    state,
    mutations,
    actions,
    getters
}